package com.hunt.controller;

import com.hunt.model.entity.CompanyPost;
import com.hunt.service.AppCompanyPostService;
import com.hunt.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * @Author sjs
 * @Date 2021/1/21
 * @Description
 */

@Api(value = "手机端-券商晨报")
@Controller
@RequestMapping("company")
public class AppCompanyPostController extends BaseController{

    @Autowired
    AppCompanyPostService appCompanyPostService;

    @ApiOperation(value = "券商晨报", httpMethod = "GET", produces = "application/json;charset=utf-8", response = Result.class)
    @ResponseBody
    @RequestMapping(value = "getCompanyPost", method = RequestMethod.GET)
    public Result getNorthRank(@RequestParam String type,
                               @RequestParam(required = false,defaultValue = "0") Integer position,
                               @RequestParam(required = false,defaultValue = "15") Integer size) {
        //type:1  代表只查询今天
        //type:1  代表只查询今天
        if (!type.equals("1"))
            return Result.param_format_error();
        return Result.success(getCompanyPost(type,position,size));
    }

    @ApiOperation(value = "app_券商晨报", httpMethod = "GET", produces = "application/json;charset=utf-8", response = Result.class)
    @ResponseBody
    @RequestMapping(value = "app_getCompanyPost", method = RequestMethod.GET)
    public Result app_getCompanyPost(@RequestParam String type,
                               @RequestParam(required = false,defaultValue = "0") Integer position,
                               @RequestParam(required = false,defaultValue = "15") Integer size) {
        //type:1  代表只查询今天
        if (!type.equals("1"))
            return Result.param_format_error();
        return Result.success(getCompanyPost(type,position,size));
    }

    private List<CompanyPost> getCompanyPost(String type,Integer position,Integer size){
        return appCompanyPostService.getCompanyPost(type,position,size);
    }
}
